package com.its.us.web.controller.sys;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.its.us.web.controller.sys.base.BaseAbsController;
import com.its.us.web.entity.sys.User;
import com.its.us.web.service.sys.UserService;
import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Author: master
 * @Date: 2020/10/28 20:54
 * @Version: 1.0
 */
@Api(tags = "测试")
@RestController
@RequestMapping("test")
public class TestController extends BaseAbsController {

    @ApiOperation(value = "测试", notes = "测试getCurrentUser", httpMethod = "GET")
    @GetMapping("testRole")
//    @PreAuthorize("hasAnyRole('admin','test')")
//    @PreAuthorize("hasRole('admin')")
    @PreAuthorize("hasPermission('/test/testRole','test:test1')")
    public Object getCurrentUser(Authentication authentication){
//        return authentication.getPrincipal();
        return "ok";
    }

    public Object success(){
        User user = new User();
        return super.ok(user);
    }
}
